package conson.tech.manage.scene.excel.converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

/**
 * @Description: 审核状态转换器
 * @author: yuwenshuo
 * @since: 2020-07-02 14:06
 */

public class OrderStateConverter implements Converter<Integer> {

    @Override
    public Class supportJavaTypeKey() {
        return Long.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.NUMBER;
    }

    @Override
    public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        String value = cellData.getStringValue();
        return TrainingEnum.AuditState.getCodeByValue(value);
    }

    @Override
    public CellData convertToExcelData(Integer aInteger, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return new CellData(TrainingEnum.OrderState.getValueByCode(aInteger));
    }
}
